//
//  Person.m
//  Test004_LearnExtension
//
//  Created by Ronald Ram on 9/29/12.
//  Copyright (c) 2012 Ronald Ram. All rights reserved.
//

#import "Person.h"

//Anonnamious Category
//Allow to have private vars and properties
@interface Person ()
{
    NSString *msg;
}

- (void) logging;

@end



@implementation Person

- (id) init
{
    return [ self initWithFName:@"Peter" AndLName:@"Pan" AndAge:10 ];
}

- (id) initWithFName:(NSString *)fn AndLName:(NSString *)ln AndAge:(int)a
{
    if ( self = [ super init ] )
    {
        FName = fn;
        LName = ln;
        _age = a;
        
        [self logging];
    }
    return self;
}


- (void) dealloc
{
    [FName release];
    [LName release];
    [msg release];
    _age = 0;
    [super dealloc];
}

@synthesize FName, LName, age = _age;

- (void)print
{
    NSLog(@"%@ msg retainCount: %u", msg, (int)[msg retainCount] );
}


//Internal Category
- (void)logging
{
    if ( msg != nil ) [msg release];
    NSLog(@"Logging Method(Before), msg retainCount: %u", (int)[msg retainCount] );
    msg = [[NSString stringWithFormat: @"%@ %@ Age: %i", FName, LName, _age] retain];
    NSLog(@"Logging Method(After), msg retainCount: %u", (int)[msg retainCount] );
}

@end
